package com.zmp.kotlinnote.java;

import android.view.View;
import android.widget.ImageView;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zmp.kotlinnote.entry.Sun;
import com.zmp.kotlinnote.entry.TUser;
import org.junit.Test;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;

import static com.zmp.kotlinnote.exchange._2_扩展函数Kt.log;
import static com.zmp.kotlinnote.exchange._2_扩展函数Kt.move;

/**
 * @author zmp
 * Created by zmp on 2018/12/25
 * TODO 重载
 */
public class _2_java {

    @Test
    public void main() {
//        J2 j2 = new J2();
//        View view = new View(null);
//        ImageView imageView = new ImageView(null);
//        j2.call(view);
//        j2.call(imageView);
//        j2.call(((View) imageView));
    }
    @Test
    public void main2() {
//       move(Sun.INSTANCE);kjj devdevdev devdevdev devdevdev devdevdev devdevdev devdevdevdevdevdev devdevdev devdevdev
//       move(Sun.INSTANCE);kjj master  master master master  master master master
//       kkj move(Sun.INSTANCE);
//
//        TUser.TUser3 tUser = new TUser.TUser3();
//        String s = JSON.toJSONString(tUser);
//        log(s);
////        TUser tUser1 = JSON.parseObject(s, TUser.class);
//        try {
//            Constructor<TUser> constructor = TUser.class.getDeclaredConstructor();
//            TUser tUser2 = constructor.newInstance();
//            tUser2.setName("aaa");
//            log(tUser2);
//        } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
//            e.printStackTrace();
//        }
////        log(tUser1);

        MapInfo mapInfo = new MapInfo();
        mapInfo.set_id(1L);
        mapInfo.setEatPoint__resolvedKey(1L);
        mapInfo.setImagePng("setImagePng");
        mapInfo.setJopPosition("setJopPosition");
        mapInfo.setMapName("setMapName");
        ArrayList<LocalPointsBean> localPointsBeans = new ArrayList<>();
        LocalPointsBean localPointsBean = new LocalPointsBean();
        LocalPointsBean localPointsBean1 = new LocalPointsBean();
        localPointsBean1.set_id(2L);
        localPointsBean1.setPointName("setPointName");
        localPointsBeans.add(localPointsBean1);
        LocalPointsBean localPointsBean2 = new LocalPointsBean();
        localPointsBean2.set_id(2L);
        localPointsBean2.setPointName("setPointName2");
        localPointsBeans.add(localPointsBean2);
        mapInfo.setPersonPoints(localPointsBeans);
        String s = JSONObject.toJSONString(mapInfo);
        log(s);
//        String s = "{\\\"mapName\\\":\\\"\\\\u4E0D\\\\u4F1Av\\\\u597Dv\\\\u597D\\\",\\\"imagePng\\\":\\\"iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAFklEQVQIHWOsr6//z4AEmJDYYCZhAQCjTgKE8mTY+AAAAABJRU5ErkJggg==\\\",\\\"knowarea_x\\\":-0.161988213658333,\\\"knowarea_y\\\":-0.158552229404449,\\\"initPoint\\\":{\\\"pointName\\\":\\\"InitPoint\\\",\\\"x\\\":-1.61846710953155,\\\"y\\\":-4.10807529854891,\\\"yaw\\\":-1.13475526734892},\\\"localPoints\\\":[],\\\"personPoints\\\":[]}\",\"isSuccess\":false}"
        MapInfo mapInfo1 = JSONObject.parseObject(s, MapInfo.class);
        log(mapInfo1);
    }


    private static class J2 {
        private void joo(View view) {
            System.out.println("view in J2");
        }

        private void joo(ImageView view) {
            System.out.println("ImageView in J2");
        }

        void call(View view) {
            joo(view);
        }

        void call(ImageView view) {
            joo(view);
        }
    }
}

